package com.jvm123.minio.service.client;

import io.minio.MinioClient;

/**
 * @author yawn http://jvm123.com
 * 2020/1/18 11:08
 */
/**
 * 默认的minio client Provider
 * @author freeman
 *
 */
public class DefaultClientProvider implements MinioClientProvider {

    private ExtendMinioClient minioClient = null;

    @Override
    public ExtendMinioClient getClient(String endpoint, String accessKey, String secretKey) {
    	// 通过double check来创建单例的Client
    	if (minioClient == null) {
        	synchronized (DefaultClientProvider.class) {
        		if (minioClient == null) {
                	minioClient = new ExtendMinioClient(MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build());
                }
			}
        }
        return minioClient;
    }
}
